import pandas as pd

# 读取Excel文件
file_path = 'F:\项目\BI\测试test.xlsx'
df = pd.read_excel(file_path, sheet_name='Sheet1', header=None)

# 获取Sheet1的第一行数据
first_row = df.iloc[0].tolist()

# 每38个数据分为一组
chunk_size = 49
chunks = [first_row[i:i + chunk_size] for i in range(0, len(first_row), chunk_size)]

# 创建一个新的DataFrame，将每个38个数据作为一行
new_df = pd.DataFrame(chunks)

# 将新的数据保存到Sheet2
with pd.ExcelWriter(file_path, engine='openpyxl', mode='a') as writer:
    new_df.to_excel(writer, sheet_name='Sheet2', index=False, header=False)

print("数据已重新调整并保存到Sheet2")

